package com.dykj.fireFighting.server.base.government.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dykj.fireFighting.api.base.government.entity.GovListApi;
import com.dykj.fireFighting.api.base.government.service.IGovListApiService;
import com.dykj.fireFighting.server.base.government.mapper.GovListApiMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.transaction.annotation.Transactional;


import java.util.List;
import java.util.Map;

/**
 * VIEW
 *
 * @Author JacksonTu
 * @Date  2022-04-26 13:59:47
 */
@Slf4j
@DubboService
@Transactional(rollbackFor = Exception.class)
public class GovListApiServiceImpl extends ServiceImpl<GovListApiMapper, GovListApi> implements IGovListApiService {


    @Override
    public GovListApi getByPSid(String pid,String sid) {
        QueryWrapper q=new QueryWrapper();
        if(StringUtils.isNotBlank(sid)){
            q.eq("sid",sid);
        }
        if(StringUtils.isNotBlank(pid)){
            q.eq("pid",pid);
        }
        q.last("limit 1");
        return getOne(q);
    }

    @Override
    public List<GovListApi> getGovListOpt(String pid) {
        QueryWrapper q=new QueryWrapper();
        q.select("sid,sname");
        if(StringUtils.isNotBlank(pid)){
            q.eq("pid",pid);
        }
        q.groupBy("sid");
        return list(q);
    }
}
